package utilities;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.apache.log4j.Logger;

public class FileConfig {
	private static Properties prop;
	private static final Logger logger = Logger.getLogger(FileConfig.class);

	static {
		try {
			if (prop == null) {
				prop = new Properties();
				prop.load(new FileInputStream(Constants.APP_CONF));
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
		}
	}

	public static String getValue(String file, String key) {
		if (file.equals(Constants.DEVP_ENV)) {
			return prop.getProperty(Constants.DEVP_ENV + "." + key);
		} else if (file.equals(Constants.PROD_ENV)) {
			return prop.getProperty(Constants.PROD_ENV + "." + key);
		} else {
			return prop.getProperty(key);
		}
	}
}
